#include "ros/ros.h"
#include "plumbing_server_client/AddInts.h"

int main( int argc, char **argv )
{
    setlocale(LC_ALL, "");
    if(argc != 3)
    {
        ROS_INFO("提交的参数不对");
        return 1;
    }
    ros::init( argc, argv, "add_ints_client" );
    ros::NodeHandle n;
    ros::ServiceClient client = n.serviceClient<plumbing_server_client::AddInts>("add_ints");
    // 组织请求
    plumbing_server_client::AddInts ai;
    ai.request.num1 = atoi(argv[1]);
    ai.request.num2 = atoi(argv[2]);
    // 
    // 如果客户端县启动，需要客户端挂起等待服务端启动
    // 判断服务器状态的函数,下述两者都可以
    // client.waitForExistence();
    ros::service::waitForService("add_ints");
    // 处理响应
    bool flag = client.call(ai);
    if(flag)
    {
        ROS_INFO("Sum:%d", ai.response.sum);
    }
    else{
        ROS_INFO("Failed");
    }


}